<template>
  <div class="box">
    <div class="left">
      <Info
        @reload="reload"
        :detailInfo="detailInfo"
        :isView="props.isView"
        :type="type"
      />
    </div>
    <div class="rig">
      <Audit
        @reload="reload"
        :detailInfo="detailInfo"
        ref="AuditRef"
        :isView="props.isView"
        :type="type"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ArrowLeft, Search } from '@element-plus/icons-vue'
import { useRoute, useRouter } from 'vue-router'
import { onMounted, ref } from 'vue'
import Info from './components/info/info.vue'
import Audit from './components/audit/audit.vue'
import { authCustom, handlerDetail } from '@/api/spotCheck/spotCheck'
import { useUserStore } from '@/store'
const userStore = useUserStore()
const router = useRouter()
const detailInfo = ref('')
const route = useRoute()
const props = defineProps({
  isView: {
    type: Boolean,
    default: () => false
  }
})

const type = ref('')
onMounted(() => {
  //type 1 整改 2 审核 3 详情
  if (route.query.type) {
    type.value = Number(route.query.type)
  }
  if (route.query.code) {
    console.log('route.query', route.query)
    authCustom({ code: route.query.code }).then((res) => {
      userStore.afterLoggingIn(res, false, 2).then((res) => {
        reload()
      })
    })
  } else {
    reload()
  }
})
const AuditRef = ref()
const reload = () => {
  handlerDetail({ sorgRiskHandleId: route.query.id }).then((res) => {
    detailInfo.value = res.data
  })
  AuditRef.value.init()
}
//返回
const goBack = () => {
  router.go(-1)
}
</script>

<style scoped lang="scss">
.box {
  width: 100%;
  display: flex;
  .left {
    flex: 1;
    min-width: 0;
  }
  .rig {
    width: 400px;
    margin-left: 21px;
  }
}
</style>
